

#import "PUMineVC.h"
#import "PUInfoModel.h"
#import "PUMineHeadCell.h"
#import "PUMineListCell.h"
#import "PURecordVC.h"
#import "BRPickerView.h"
#import "PUInfoModel.h"
#import <QCloudCOSXML/QCloudCOSXMLTransfer.h>
#import <CoreLocation/CoreLocation.h>

#import "TZImagePickerController.h"
#import "UIView+TZLayout.h"
#import "TZTestCell.h"
#import <Photos/Photos.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "MSCTakePictureViewController.h"
#import "PUEditNicknameView.h"
#import "PUUpdateView.h"
#import "PUAboutUsVC.h"
#import "PUNoTitleTipView.h"
@interface PUMineVC ()<UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate,TZImagePickerControllerDelegate,CPInvitationCodeViewDelegate,FLUpdateViewDelegate,FLNoTitleTipViewDelegate>{
    CLLocationManager   *_lbsManager;
    NSString * uploadFilePath;
    
    NSMutableArray *_selectedPhotos;
    NSMutableArray *_selectedAssets;
    BOOL _isSelectOriginalPhoto;
    BOOL _isAllowEditVideo;
}
@property (nonatomic,retain)UITableView *tableView;
@property (nonatomic,retain)NSMutableArray *imageData;
@property (nonatomic,retain)NSMutableArray *titleData;
@property (nonatomic,retain)NSMutableArray *myData;
@property (nonatomic,retain)NSMutableArray *bannerData;
@property (nonatomic)int sex;
@property (nonatomic,retain)NSMutableArray *signData;
@property (nonatomic)int is_complete_today;
@property (nonatomic)int start_day;
@property (nonatomic,retain)NSString *desc;
@property(nonatomic,strong)PUUpdateView* CPUpdateView;
@end

@implementation PUMineVC


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.myData=[NSMutableArray array];
    self.signData=[NSMutableArray array];
    self.bannerData=[NSMutableArray array];
    
    PUInfoModel *model1=[[PUInfoModel alloc]init];
    model1.title=@"隐私协议";
    model1.icon=@"hua充值";
    model1.link=@"隐私协议背景";
    
    [self.myData addObject:model1];
    
    PUInfoModel *model2=[[PUInfoModel alloc]init];
    model2.title=@"用户协议";
    model2.icon=@"hua淘花记录";
    model2.link=@"用户协议背景";
    [self.myData addObject:model2];
    
    PUInfoModel *model3=[[PUInfoModel alloc]init];
    model3.title=@"检测新版本";
    model3.icon=@"hua观花记录";
    model3.link=@"检测新版本背景";
    [self.myData addObject:model3];
    
    PUInfoModel *model4=[[PUInfoModel alloc]init];
    model4.title=@"关于我们";
    model4.icon=@"hua观花记录";
    model4.link=@"关于我们背景";
    [self.myData addObject:model4];

    
    UIImageView *img=[[UIImageView alloc]init];
    img.backgroundColor=[UIColor whiteColor];
    img.image=[UIImage imageNamed:@"我的背景"];
    [self.view addSubview:img];
    
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(0);
        make.left.equalTo(self.view.mas_left).offset(0);
        make.right.equalTo(self.view.mas_right).offset(0);
        make.bottom.equalTo(self.view.mas_bottom).offset(0);
       
    }];
    
    
    _tableView = [[UITableView alloc] init];
//    _tableView.backgroundColor=[UIColor colorWithHex:0xFAFCFF];
    _tableView.backgroundColor=[UIColor clearColor];
    //解决scrollToRowAtIndexPath：滚动位置偏差问题
    _tableView.estimatedRowHeight = 0;
    _tableView.estimatedSectionFooterHeight = 0;
    _tableView.estimatedSectionHeaderHeight = 0;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//设置分隔线样式
    _tableView.bounces = YES;
    _tableView.delegate=self;
    _tableView.dataSource=self;
    [self.view addSubview:self.tableView];
    self.edgesForExtendedLayout = UIRectEdgeTop;
    _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    
    
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(0);
        make.left.equalTo(self.view.mas_left).offset(0);
        make.right.equalTo(self.view.mas_right).offset(0);
        make.bottom.equalTo(self.view.mas_bottom).offset(0);
    }];
    
    
    UIButton *updateBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [updateBtn setBackgroundColor:[UIColor whiteColor]];
//    updateBtn.frame = CGRectMake(16*KWidthScale,_window_height-KWidthScale*48-46, self.view.bounds.size.width-16*KWidthScale*2,KWidthScale*48);
//    updateBtn.clipsToBounds = YES;
    updateBtn.layer.masksToBounds=YES;
    updateBtn.layer.cornerRadius =48*KWidthScale/2;
    [updateBtn addTarget:self action:@selector(addTipView) forControlEvents:UIControlEventTouchUpInside];
    [updateBtn setTitle:@"退出登录" forState:UIControlStateNormal];
    updateBtn.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [updateBtn setTitleColor:[UIColor colorWithHex:0xFF729A] forState:UIControlStateNormal];
    [self.view addSubview:updateBtn];
    
    [updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.view.mas_top).offset(0);
        make.height.equalTo(@(48*KWidthScale));
        make.left.equalTo(self.view.mas_left).offset(12);
        make.right.equalTo(self.view.mas_right).offset(-12);
        make.bottom.equalTo(self.view.mas_bottom).offset(-12);
    }];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatecommon) name:@"commonNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:@"loginSuccessUpdataNotification" object:nil];//登录成功
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOutSuccess:) name:@"showLoginNotification" object:nil];//退出登录成功，隐藏签到
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(kickout) name:@"kickoutNotification" object:nil]; //其他设备登录时，通知回到一级页面
    
//    [self loadSignList];

//    CPHelloSetVC *vc=[[CPHelloSetVC alloc]init];
//    [self.navigationController pushViewController:vc animated:YES];
    
//    CPYZMView *v= [[CPYZMView alloc] initWithCPYZMView];
//    v.delegate=self;
//    [v show];
    
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self resetSideBack];
    
    self.navigationController.navigationBar.translucent = YES;
    if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *barApp = [UINavigationBarAppearance new];
        barApp.backgroundColor = [UIColor clearColor];
        barApp.backgroundEffect = nil;
        barApp.shadowColor = nil;
        self.navigationController.navigationBar.scrollEdgeAppearance = barApp;
        self.navigationController.navigationBar.standardAppearance = barApp;
    }else{
        [self.navigationController.navigationBar setShadowImage:[UIImage new]];
        [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    }
}
/*
 恢复边缘返回
 */
- (void)resetSideBack {
    //开启ios右滑返回
    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    }
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
    return YES;
}
-(void)loginSuccess{
//    [self loadSignList];
}
-(void)kickout{
    [self.navigationController popToRootViewControllerAnimated:NO];
}
//退出登录
-(void)loginOutSuccess:(NSNotification*)notification
{
    [self.signData removeAllObjects];
    [self.tableView reloadData];
    [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
-(void)updatecommon{
    return;
    NSDictionary *info_api = [Config getLaunch_api];
    NSLog(@"%@",info_api);
    NSArray *my=info_api[@"my"];
    NSLog(@"%@",my);
    
    self.myData= [PUInfoModel mj_objectArrayWithKeyValuesArray:info_api[@"my"]];
    NSLog(@"%@",self.myData);
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.translucent = NO;
    UIColor *color = [UIColor whiteColor];
    if (@available(iOS 15.0, *)) {
        self.navigationController.navigationBar.standardAppearance.backgroundColor = color;
        self.navigationController.navigationBar.scrollEdgeAppearance.backgroundColor = color;
    }else{
        self.navigationController.navigationBar.barTintColor = color;
    }
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
   
    [self.tableView reloadData];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row==0){
        return 208*KWidthScale;
    }
    return 92*KWidthScale;//55
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.myData.count+1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if(indexPath.row==0){

        static NSString *cellIdentifier1 = @"XLMineHeadCell";//定义一个可重用标识
        PUMineHeadCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier1];//从重用队列里获取可重用的cell
        if (cell==nil)
        {
            //如果不存在，创建一个可重用cell
            cell =[[PUMineHeadCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1] ;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
       
        cell.nameLab.text=[Config getnickname]!=nil?[Config getnickname]:@"";
        if([Config getAvatar]==nil||[[Config getAvatar] isEqualToString:@""]){
            cell.headImage.image=[UIImage imageNamed:@"manHead"];
        }else{
            
//            NSLog(@"%@",[Config getOriginal_avatar]);//https://cos.nnyc123.cn/common/app/male.png
            NSString *avatar=[Config getOriginal_avatar];
            NSDictionary *saveOpen_app_config = [Config getOpenAppConfig];
            NSString *cos_url=@"";
            NSString *cos_auth=@"";
            NSString *urlSuffix=@"";
            if (saveOpen_app_config!=nil) {
                cos_url=saveOpen_app_config[@"cos_url"];
                NSLog(@"%@",cos_url);//https://cos.nnyc123.cn
                
                cos_auth=saveOpen_app_config[@"cos_auth"];
                NSLog(@"%@",cos_auth);//ssM7AOlb5Xio2015kLKmayc
                urlSuffix = [avatar substringFromIndex:cos_url.length];
                NSLog(@"%@",urlSuffix);//common/app/male.png
                
                NSString *timeStamp=[AES128 getNowTimeStamp];//1744628907
                NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
                NSString *str=[NSString stringWithFormat:@"MineHeadtimeStamp%@",[Config getID]];
                NSString *t=[userDefaults objectForKey:str];
                if (t!=nil&&![t isEqualToString:@""]) {
                    timeStamp=t;
                }else{
                    [userDefaults setObject:timeStamp forKey:str];
                    [userDefaults synchronize];
                }
                NSString *urlStr=[NSString stringWithFormat:@"%@%@%@",cos_auth,urlSuffix,timeStamp];
                NSLog(@"%@",urlStr);//ssM7AOlb5Xio2015kLKmayc/common/app/male.png1744628907
                NSData *data = [urlStr dataUsingEncoding:NSUTF8StringEncoding];
                 
                if (data) {
                    // 转换成功，data 包含了UTF-8编码的字节数组
                    // 例如，你可以将NSData写入文件或通过网络发送
                    NSLog(@"转换成功");
                    
                    NSData *md5Result = [AES128 dataWithMD5Hash:data];
                    NSString *hexString = [AES128 hexStringFromData:md5Result];
                    
                    NSString *url=[NSString stringWithFormat:@"%@?sign=%@&t=%@",avatar,hexString,timeStamp];
                    [cell.headImage sd_setImageWithURL:[NSURL URLWithString:url]];
                } else {
                    // 转换失败
                    NSLog(@"Failed to convert string to NSData.");
                }
            }
        }
        
        cell.headImage.contentMode=UIViewContentModeScaleAspectFill;
        cell.headImage.backgroundColor=[UIColor colorWithHex:0xF2F2F2];
        cell.IDLab.text=[NSString stringWithFormat:@"ID：%@",[Config getShow_number]!=nil?[Config getShow_number]:@""];
        
       
        
        
        CGSize titleLabSize1 = [cell.nameLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17]}];
        CGFloat titleLabWidth1 = ceil(titleLabSize1.width);
        
        cell.nameLab.frame = CGRectMake(_window_width/2-titleLabWidth1/2,cell.headImage.frame.origin.y+cell.headImage.frame.size.height+12*KWidthScale, titleLabWidth1, 22*KWidthScale);
        
        cell.imageview.frame=CGRectMake(cell.nameLab.frame.origin.x+cell.nameLab.frame.size.width+5, cell.nameLab.frame.origin.y+3, 16*KWidthScale, 16*KWidthScale);
        //头像
        cell.headImage.userInteractionEnabled=YES;
        UITapGestureRecognizer *headImageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headImageGesture)];
        [cell.headImage addGestureRecognizer:headImageTap];
        cell.nameLab.userInteractionEnabled=YES;
        UITapGestureRecognizer *nameLabTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(nameLabGesture)];
        [cell.nameLab addGestureRecognizer:nameLabTap];
        
        cell.imageview.userInteractionEnabled=YES;
        UITapGestureRecognizer *imageviewTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(nameLabGesture)];
        [cell.imageview addGestureRecognizer:imageviewTap];
        cell.backgroundColor=[UIColor clearColor];
        return cell;
    }
    
    PUInfoModel *model=self.myData[indexPath.row-1];
    static NSString *cellIdentifier1 = @"XLMineListCell";//定义一个可重用标识
    PUMineListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier1];//从重用队列里获取可重用的cell
    if (cell==nil)
    {
        //如果不存在，创建一个可重用cell
        cell =[[PUMineListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1] ;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.bgImage.image=[UIImage imageNamed:model.link];
    cell.backgroundColor=[UIColor clearColor];
    cell.deatilLab.hidden=YES;
    [cell.titleBtn setTitle:model.title forState:UIControlStateNormal];
    cell.img.image=[UIImage imageNamed:model.icon];
    cell.deatilLab.hidden=YES;
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
//    CPQSNMSVC *vc=[[CPQSNMSVC alloc]init];
//    [self.navigationController pushViewController:vc animated:YES];
//    return;

    if (indexPath.row==1) {
        [self pushprivacy_policy];
      
    }
    if (indexPath.row==2) {
        [self pushuser_agreement];
    }
    if (indexPath.row==3) {
        [self loadsystemversion];
    }
    if (indexPath.row==4) {
        PUAboutUsVC *vc=[[PUAboutUsVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
   
}
-(void)pushprivacy_policy{
    NSDictionary *saveOpen_app_config = [Config getOpenAppConfig];
    NSString *h5_url=@"";
    if (saveOpen_app_config!=nil) {
        h5_url=saveOpen_app_config[@"h5_url"];
    }
    NSString* url = [NSString stringWithFormat:@"%@%@?p=4",h5_url,@"privacy_policy"];
    PUWebViewVC *vc=[[PUWebViewVC alloc]init];
    vc.is_topbar=0;
    vc.url=url;
    vc.titleStr=@"隐私协议";
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)pushuser_agreement{
    NSDictionary *saveOpen_app_config = [Config getOpenAppConfig];
    NSString *h5_url=@"";
    if (saveOpen_app_config!=nil) {
        h5_url=saveOpen_app_config[@"h5_url"];
    }
    NSString* url = [NSString stringWithFormat:@"%@%@?p=4",h5_url,@"user_agreement"];
    PUWebViewVC *vc=[[PUWebViewVC alloc]init];
    vc.is_topbar=0;
    vc.url=url;
    vc.titleStr=@"用户服务协议";
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)loadsystemversion{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *v=[NSString stringWithFormat:@"%@",[infoDictionary objectForKey:@"CFBundleShortVersionString"]];
    NSDictionary *param =@{
                            @"channel_id":@(1),
                            @"platform":@(2),
                          };
                   
    NSString *path=@"/system/version";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            NSString *desc=dic[@"desc"];
            NSString *version=dic[@"version"];
            NSString *version_code=dic[@"version_code"];
            int is_force=[dic[@"is_force"] intValue];
            NSString *download_url=dic[@"download_url"];
//            if (desc!=nil&&![desc isEqualToString:@""]) {
            if (![version_code isEqualToString:v]) {
                if(!self.CPUpdateView){
                    PUUpdateView *v=[[PUUpdateView alloc]initWithCPUpdateViewInfo:desc version:version is_force:is_force link:download_url link_type:0];
                    v.delegate=self;
                    [v show];
                    self.CPUpdateView=v;
                }
            }else{
                [self showSVProgressHUDStr:@"当前已经最新版本"];
            }
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
    } failure:^(NSError *error) {
        NSLog(@"错误：%@",error);
    }];
}
//关闭
-(void)CPUpdateViewUpdateClose{
    [self.CPUpdateView removeFromSuperview];
    self.CPUpdateView=nil;
}
-(void)addTipView{
    PUNoTitleTipView *view=[[PUNoTitleTipView alloc]initCPTipViewWithContent:@"确定退出登录？" confirmStr:@"确定" cancelStr:@"取消" buttonCount:2];
    view.delegate=self;
    [view show];
}
-(void)CPNoTitleTipViewbtnClickedIndex:(int)index{
    if(index==1){
      [self confirmClick];
    }
}
//立即更新
-(void)CPUpdateViewUpdateBtnClicklink:(NSString *)link link_type:(int)link_type is_force:(int)is_force{
    if (is_force==0) {
        [self.CPUpdateView removeFromSuperview];
        self.CPUpdateView=nil;
    }
    
    
//    NSString *APP_ID=@"6504002201";
//    NSString *str = [NSString stringWithFormat:@"https://itunes.apple.com/cn/app/id%@", APP_ID];
//    link=[NSString stringWithFormat:@"https://itunes.apple.com/cn/app/id%@", APP_ID];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:link] options:@{} completionHandler:nil];
}

-(void)confirmClick{
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD show ];

    NSDictionary *param =@{
                           
                          };
                   
    NSString *path=@"/auth/logout";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        [SVProgressHUD dismiss];
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
          
            [Config clearProfile];
            self.tabBarController.selectedIndex = 0;
            [[NSNotificationCenter defaultCenter] postNotificationName:@"showLoginNotification" object:self userInfo:@{@"code":@"0"}];
//            [self.navigationController popViewControllerAnimated:NO];
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
    } failure:^(NSError *error) {
        [SVProgressHUD dismiss];
        NSLog(@"错误：%@",error);
    }];
}
-(void)showSVProgressHUDStr:(NSString *)str{
    if ([str isKindOfClass:[NSNull class]]||str==nil||[str isEqualToString:@""]) {
        return;
    }
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:str];
}


//头像点击
-(void)headImageGesture{

    UIAlertController *alerController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
      
        
    }];
    
    UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"从相册上传" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self pushTZImagePickerController];
    }];
    
    UIAlertAction *confirmAction2 = [UIAlertAction actionWithTitle:@"手机拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self aaa];
    }];
    
   
    [alerController addAction:confirmAction];
    [alerController addAction:confirmAction2];
    [alerController addAction:cancelAction];
    
    [self presentViewController:alerController animated:YES completion:^{
        
    }];
    
}
-(void)nameLabGesture{
    PUEditNicknameView *v= [[PUEditNicknameView alloc] initWithFoodEditNicknameView:[Config getnickname]];
    v.delegate=self;
    [v show];
}


-(void)CPInvitationCodeViewSureCode:(NSString *)code{
    if (code==nil||[code isEqualToString:@""]) {
        [self showSVProgressHUDStr:@"昵称不能为空"];
        return;
    }

    NSDictionary *param =@{
                           @"nickname":code,
                           };
    NSString *path=@"/user/app_set_profile";
    path=@"/user/edit";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            [self showSVProgressHUDStr:@"昵称修改成功"];
            LiveUser *user = [[LiveUser alloc] init];
            user.nickname = code;
            [Config updateProfile:user];
            [self.tableView reloadData];
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
    } failure:^(NSError *error) {
        NSLog(@"错误：%@",error);
    }];
}

-(void)loadSignList{
    
}
-(void)CPQDViewBtnClick{
    
}
-(void)CPQDSuccessViewBtnClick{
    NSLog(@"获取更多金币");
}
-(void)loadCommonInit{
  
//    NSString *url = [NSString stringWithFormat:@"%@/common/init",userpurl];
//    [[AFNetManager shareManager] getDataWithURLString:url parameters:nil success:^(NSURLResponse *operation, id successObject) {
//        NSLog(@"%@",successObject);
//        //        NSString *dataStr= successObject[@"data"];
//        if ([successObject[@"code"] integerValue] == 0) {
//            
//            NSDictionary *info_api1 = [Config getLaunch_api];
//            //        NSLog(@"%@",info_api1);
//            if (info_api1!=nil) {
//                NSArray *my=info_api1[@"my"];
//                NSLog(@"%@",my);
//            }
//            
//            NSDictionary *info = successObject[@"data"][@"my"];
//            NSLog(@"%@",info);
//            if (info!=nil) {
//                
//                NSArray *my=info_api1[@"my"];
//                NSMutableDictionary * a=[NSMutableDictionary dictionaryWithDictionary:info_api1];
//                
//                
//                [a setValue:info forKey:@"my"];
//                [Config saveLaunch_apiInfo:a];
//                
//                NSDictionary *info_api2 = [Config getLaunch_api];
//                NSLog(@"%@",info_api2);
//                
//                self.myData= [FLInfoModel mj_objectArrayWithKeyValuesArray:info_api2[@"my"]];
//                NSLog(@"%@",self.myData);
//                [self.tableView reloadData];
//            }
//           
//        }else{
//            //            [self showSVProgressHUDStr:successObject[@"message"]];
//        }
//        
//    } failure:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
}

-(void)showCPZRRZView{
    
}
//立即认证
-(void)CPZRRZViewBtnClick{
    
}



#pragma mark - TZImagePickerController

- (void)pushTZImagePickerController {
//    if (self.maxCountTF.text.integerValue <= 0) {
//        return;
//    }
    // 设置languageBundle以使用其它语言，必须在TZImagePickerController初始化前设置 / Set languageBundle to use other language
//     [TZImagePickerConfig sharedInstance].languageBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"zh-Hans" ofType:@"lproj"]];

    TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 columnNumber:4 delegate:self pushPhotoPickerVc:YES];
    
#pragma mark - 五类个性化设置，这些参数都可以不传，此时会走默认设置
    imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
    
//    if (self.maxCountTF.text.integerValue > 1) {
        // 1.设置目前已经选中的图片数组
//        imagePickerVc.selectedAssets = _selectedAssets; // 目前已经选中的图片数组
//    }
    imagePickerVc.allowTakePicture = NO; // 在内部显示拍照按钮
    imagePickerVc.allowTakeVideo = NO;   // 在内部显示拍视频按
    imagePickerVc.videoMaximumDuration = 10; // 视频最大拍摄时间
    imagePickerVc.allowEditVideo = YES; // 允许编辑视频
    // imagePickerVc.saveEditedVideoToCollection = YES; // 编辑后的视频是否自动保存到相册
    // imagePickerVc.maxCropVideoDuration = 30; // 裁剪视频的最大时长
    // imagePickerVc.presetName = AVAssetExportPresetMediumQuality // 编辑后的视频的导出质量
    [imagePickerVc setUiImagePickerControllerSettingBlock:^(UIImagePickerController *imagePickerController) {
        imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
    }];
    // imagePickerVc.autoSelectCurrentWhenDone = NO;
    
    // imagePickerVc.photoWidth = 1600;
    // imagePickerVc.photoPreviewMaxWidth = 1600;
    
    // 2. Set the appearance
    // 2. 在这里设置imagePickerVc的外观
    // imagePickerVc.navigationBar.barTintColor = [UIColor greenColor];
    // imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
    // imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor];
    // imagePickerVc.barItemTextColor = [UIColor blackColor];
    // imagePickerVc.navigationBar.translucent = NO;
    // [imagePickerVc.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];
    // imagePickerVc.navigationBar.tintColor = [UIColor blackColor];
    // if (@available(iOS 13.0, *)) {
    //     UINavigationBarAppearance *barAppearance = [[UINavigationBarAppearance alloc] init];
    //     barAppearance.backgroundColor = imagePickerVc.navigationBar.barTintColor;
    //     barAppearance.titleTextAttributes = imagePickerVc.navigationBar.titleTextAttributes;
    //     imagePickerVc.navigationBar.standardAppearance = barAppearance;
    //     imagePickerVc.navigationBar.scrollEdgeAppearance = barAppearance;
    // }
    
    imagePickerVc.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
    imagePickerVc.showPhotoCannotSelectLayer = YES;
    imagePickerVc.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
    /*
    [imagePickerVc setPhotoPickerPageUIConfigBlock:^(UICollectionView *collectionView, UIView *bottomToolBar, UIButton *previewButton, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel, UIView *divideLine) {
        [doneButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    }];
     */
    /*
    [imagePickerVc setAssetCellDidSetModelBlock:^(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView) {
        cell.contentView.clipsToBounds = YES;
        cell.contentView.layer.cornerRadius = cell.contentView.tz_width * 0.5;
    }];
     */
    
    // 3. Set allow picking video & photo & originalPhoto or not
    // 3. 设置是否可以选择视频/图片/原图
    
    
    
    
//    if (self.type==1) {
        imagePickerVc.allowPickingVideo = NO;
        imagePickerVc.allowPickingImage = YES;
//    }else{
//        imagePickerVc.allowPickingVideo = YES;
//        imagePickerVc.allowPickingImage = NO;
//    }
    imagePickerVc.allowPickingOriginalPhoto = NO;
    imagePickerVc.allowPickingGif = NO;
    imagePickerVc.allowPickingMultipleVideo = NO; // 是否可以多选视频
    
    // 4. 照片排列按修改时间升序
    imagePickerVc.sortAscendingByModificationDate = YES;
    
    // imagePickerVc.minImagesCount = 3;
    // imagePickerVc.alwaysEnableDoneBtn = YES;
    
    // imagePickerVc.minPhotoWidthSelectable = 3000;
    // imagePickerVc.minPhotoHeightSelectable = 2000;
    
    /// 5. Single selection mode, valid when maxImagesCount = 1
    /// 5. 单选模式,maxImagesCount为1时才生效
    imagePickerVc.showSelectBtn = NO;
    imagePickerVc.allowCrop = NO;
    imagePickerVc.needCircleCrop = NO;
    // 设置竖屏下的裁剪尺寸
    NSInteger left = 30;
    NSInteger widthHeight = self.view.tz_width - 2 * left;
    NSInteger top = (self.view.tz_height - widthHeight) / 2;
    if ([TZCommonTools tz_isLandscape]) {
        top = 30;
        widthHeight = self.view.tz_height - 2 * left;
        left = (self.view.tz_width - widthHeight) / 2;
    }
    imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
    imagePickerVc.scaleAspectFillCrop = YES;
    // 设置横屏下的裁剪尺寸
    // imagePickerVc.cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, left, widthHeight, widthHeight);
    /*
     [imagePickerVc setCropViewSettingBlock:^(UIView *cropView) {
     cropView.layer.borderColor = [UIColor redColor].CGColor;
     cropView.layer.borderWidth = 2.0;
     }];*/
    
    // imagePickerVc.allowPreview = NO;
    // 自定义导航栏上的返回按钮
    /*
    [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
        [leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 20)];
    }];
    imagePickerVc.delegate = self;
    */
    
    // Deprecated, Use statusBarStyle
    // imagePickerVc.isStatusBarDefault = NO;
    imagePickerVc.statusBarStyle = UIStatusBarStyleLightContent;
    
    // 设置是否显示图片序号
    imagePickerVc.showSelectedIndex = YES;
    
    // 设置拍照时是否需要定位，仅对选择器内部拍照有效，外部拍照的，请拷贝demo时手动把pushImagePickerController里定位方法的调用删掉
    // imagePickerVc.allowCameraLocation = NO;
    
    // 自定义gif播放方案
//    [[TZImagePickerConfig sharedInstance] setGifImagePlayBlock:^(TZPhotoPreviewView *view, UIImageView *imageView, NSData *gifData, NSDictionary *info) {
//        FLAnimatedImage *animatedImage = [FLAnimatedImage animatedImageWithGIFData:gifData];
//        FLAnimatedImageView *animatedImageView;
//        for (UIView *subview in imageView.subviews) {
//            if ([subview isKindOfClass:[FLAnimatedImageView class]]) {
//                animatedImageView = (FLAnimatedImageView *)subview;
//                animatedImageView.frame = imageView.bounds;
//                animatedImageView.animatedImage = nil;
//            }
//        }
//        if (!animatedImageView) {
//            animatedImageView = [[FLAnimatedImageView alloc] initWithFrame:imageView.bounds];
//            animatedImageView.runLoopMode = NSDefaultRunLoopMode;
//            [imageView addSubview:animatedImageView];
//        }
//        animatedImageView.animatedImage = animatedImage;
//    }];
    
    // 设置首选语言 / Set preferred language
    // imagePickerVc.preferredLanguage = @"zh-Hans";
    
#pragma mark - 到这里为止
    
    // You can get the photos by block, the same as by delegate.
    // 你可以通过block或者代理，来得到用户选择的照片.
    [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {

    }];
    
    imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:imagePickerVc animated:YES completion:nil];
}
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos {
    _isAllowEditVideo = NO;
    _selectedPhotos = [NSMutableArray arrayWithArray:photos];
    _selectedAssets = [NSMutableArray arrayWithArray:assets];
    _isSelectOriginalPhoto = isSelectOriginalPhoto;
    
    if (_selectedPhotos.count>0) {
        UIImage *image=self->_selectedPhotos[0];
        NSData *data;
        if (UIImagePNGRepresentation(image) == nil) {
            data = UIImageJPEGRepresentation(image, 1.0);
        } else {
            data = UIImagePNGRepresentation(image);
        }
        [self loadUpload_token:data];
        //先显示要发的图片
//        if (_delegate && [_delegate respondsToSelector:@selector(chatBoxViewController:uploadFilePath:imageData:)]) {
//
//            [_delegate chatBoxViewController:self uploadFilePath:@"" imageData:data];//base对 进行旋转压缩后发送
//        }
        
    }
 
    // _collectionView.contentSize = CGSizeMake(0, ((_selectedPhotos.count + 2) / 3 ) * (_margin + _itemWH));

    // 1.打印图片名字
//    [self printAssetsName:assets];
    // 2.图片位置信息
//    for (PHAsset *phAsset in assets) {
//        NSLog(@"location:%@",phAsset.location);
//    }

    // 3. 获取原图的示例，用队列限制最大并发为1，避免内存暴增
//    self.operationQueue = [[NSOperationQueue alloc] init];
//    self.operationQueue.maxConcurrentOperationCount = 1;
//    for (NSInteger i = 0; i < assets.count; i++) {
//        PHAsset *asset = assets[i];
//        // 图片上传operation，上传代码请写到operation内的start方法里，内有注释
//        TZImageUploadOperation *operation = [[TZImageUploadOperation alloc] initWithAsset:asset completion:^(UIImage * photo, NSDictionary *info, BOOL isDegraded) {
//            if (isDegraded) return;
//            NSLog(@"图片获取&上传完成");
//        } progressHandler:^(double progress, NSError * _Nonnull error, BOOL * _Nonnull stop, NSDictionary * _Nonnull info) {
//            NSLog(@"获取原图进度 %f", progress);
//        }];
//        [self.operationQueue addOperation:operation];
//    }
}

-(void)loadUpload_token:(NSData *)imagedata{
    
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD show ];
    [SVProgressHUD showWithStatus:@"正在提交中，请稍后..."];
    
    NSDictionary *param =@{
        @"type":@(1)
    };
    NSString *path=@"/system/upload_token";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            
            NSString *expiredTime=[NSString stringWithFormat:@"%@",dic[@"expiredTime"]];//过期时间戳
            NSString *expiration=[NSString stringWithFormat:@"%@",dic[@"expiration"]];//过期时间字符串
            NSString *requestId=[NSString stringWithFormat:@"%@",dic[@"requestId"]];//请求ID
            NSString *startTime=[NSString stringWithFormat:@"%@",dic[@"startTime"]];//开始时间戳
            NSDictionary *credentials=dic[@"credentials"];//上传凭证信息
            NSString *prefix=[NSString stringWithFormat:@"%@",dic[@"prefix"]];//上传凭证信息
            
            NSString *sessionToken=[NSString stringWithFormat:@"%@",credentials[@"sessionToken"]];//会话令牌
            NSString *tmpSecretId=[NSString stringWithFormat:@"%@",credentials[@"tmpSecretId"]];//临时密钥ID
            NSString *tmpSecretKey=[NSString stringWithFormat:@"%@",credentials[@"tmpSecretKey"]];//临时密钥Key
            [self uploadExpiredTime:expiredTime expiration:expiration requestId:requestId startTime:startTime prefix:prefix sessionToken:sessionToken tmpSecretId:tmpSecretId tmpSecretKey:tmpSecretKey uploadFilePath:@"" imageData:imagedata imageOrAudio:@"" audioData:nil duration:@"0"];
        } else {
            [SVProgressHUD dismiss];
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
        
    } failure:^(NSError *error) {
        [SVProgressHUD dismiss];
        NSLog(@"错误：%@",error);
    }];
}

-(void)uploadExpiredTime:(NSString *)expiredTime expiration:(NSString *)expiration requestId:(NSString *)requestId  startTime:(NSString *)startTime  prefix:(NSString *)prefix  sessionToken:(NSString *)sessionToken  tmpSecretId:(NSString *)tmpSecretId  tmpSecretKey:(NSString *)tmpSecretKey uploadFilePath:(NSString *)uploadFilePath imageData:(NSData *)imageData imageOrAudio:(NSString *)imageOrAudio audioData:(NSData *)audioData duration:(NSString *)duration{
    
    
    int randomNumber = arc4random_uniform(900) + 100;
    NSString *timeStamp=[AES128 getNowTimeStamp];
    NSString *houzhuo=@".jpg";
    NSString *object=[NSString stringWithFormat:@"%@%@%d%@",prefix,timeStamp,randomNumber,houzhuo];
    NSDictionary *saveOpen_app_config1 = [Config getOpenAppConfig];
    
    NSString *cos_bucket_name=@"";
    NSString *cos_region=@"";
    NSString *cos_url=@"";
    
    if (saveOpen_app_config1!=nil) {
        cos_bucket_name=saveOpen_app_config1[@"cos_bucket_name"];
        cos_region=saveOpen_app_config1[@"cos_region"];
        cos_url=saveOpen_app_config1[@"cos_url"];
    }
    
    QCloudServiceConfiguration* configuration = [QCloudServiceConfiguration new];
    //        configuration.appID = @"1250000000";
    QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] init];
    endpoint.regionName = cos_region;
    // 使用 HTTPS
    endpoint.useHTTPS = true;
    configuration.endpoint = endpoint;
    // 初始化 COS 服务示例
    [QCloudCOSXMLService registerDefaultCOSXMLWithConfiguration:configuration];
    [QCloudCOSTransferMangerService registerDefaultCOSTransferMangerWithConfiguration:
     configuration];
    
    NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:[startTime integerValue]];
    NSDate *expirationDate = [NSDate dateWithTimeIntervalSince1970:[expiredTime integerValue]];
    
    QCloudCOSXMLUploadObjectRequest* put = [QCloudCOSXMLUploadObjectRequest new];
    QCloudCredential * credential = [QCloudCredential new];
    credential.secretID = tmpSecretId;
    credential.secretKey = tmpSecretKey;
    credential.token = sessionToken;
    credential.startDate = startDate;
    credential.expirationDate = expirationDate;
    put.credential = credential;
    put.bucket = cos_bucket_name;
    put.object = object;
    put.body=imageData;
    //监听上传进度
    [put setSendProcessBlock:^(int64_t bytesSent,
                               int64_t totalBytesSent,
                               int64_t totalBytesExpectedToSend) {
        //      bytesSent                 本次要发送的字节数（一个大文件可能要分多次发送）
        //      totalBytesSent            已发送的字节数
        //      totalBytesExpectedToSend  本次上传要发送的总字节数（即一个文件大小）
        float progress = 1.f * totalBytesSent / totalBytesExpectedToSend;
        NSLog(@"上传文件进度: %f", progress);
    }];
    
    //监听上传结果
    [put setFinishBlock:^(id outputObject, NSError *error) {
        
        //可以从 outputObject 中获取 response 中 etag 或者自定义头部等信息
        NSDictionary * result = (NSDictionary *)outputObject;
        NSLog(@"%@",result);
        if (error==nil) {
            NSString *url=[NSString stringWithFormat:@"%@%@",cos_url,object];
            
            dispatch_async(dispatch_get_main_queue(), ^{
                [SVProgressHUD dismiss];
                [self loadImageUrl:url];
            });
            
        }else{
            [SVProgressHUD dismiss];
            [self showSVProgressHUDStr:@"上传失败"];
        }
        
    }];
    [[QCloudCOSTransferMangerService defaultCOSTransferManager] UploadObject:put];
    
}

-(void)loadImageUrl:(NSString *)url{
    
    //    NSDictionary *param =@{
    //                           @"link":url,
    //                           };
    //    NSString *path=@"/user/avatar";
    //
    //    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    //    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
    //        [SVProgressHUD dismiss];
    //        NSString *result=successObject[@"result"];
    //        NSDictionary *dic=@{};
    //        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
    //            //解密Base64编码的字符串
    //            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
    //            dic=[AES128 dictionaryWithJsonString:decryptedString];
    //            NSLog(@"json解析===%@",dic);
    //        }
    //
    //        if ([successObject[@"code"] integerValue] == 200) {
    //            [self showSVProgressHUDStr:@"头像上传成功"];
    //        } else {
    //            [self showSVProgressHUDStr:successObject[@"message"]];
    //        }
    //
    //    } failure:^(NSError *error) {
    //        [SVProgressHUD dismiss];
    //        NSLog(@"错误：%@",error);
    //
    //    }];
    
    NSDictionary *param =@{
                          @"person_pic":url,
                          };
    NSString *path=@"/user/avatar";
    
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        [SVProgressHUD dismiss];
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            NSLog(@"修改成功");
            LiveUser *user = [[LiveUser alloc] init];
            user.original_avatar = url;
            [Config updateProfile:user];
            
            [self.tableView reloadData];
            [self showSVProgressHUDStr:@"头像上传成功"];
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
    } failure:^(NSError *error) {
        [SVProgressHUD dismiss];
        NSLog(@"错误：%@",error);
    }];
}
-(void)aaa{
    MSCTakePictureViewController *faceVC = [[MSCTakePictureViewController alloc]init];
    faceVC.takePictureType = MSCTakePictureTypePhoto;
    faceVC.isShowChangeCameraBtn=YES;
    faceVC.block = ^(BOOL isFinished, NSData *imageData, UIImage *image){
        if (isFinished)
        {


            NSDate *date=[NSDate date];
            
            NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
            NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"currentImage"];
            [imageData writeToFile:fullPath atomically:NO];
            
            [self loadUpload_token:imageData];
            
          
        }
    };
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:faceVC];
    nav.modalPresentationStyle=0;
    [self presentViewController:nav animated:YES completion:nil];
}
@end
